package com.atolcd.pentaho.di.gis.io.features;

/*
 * #%L
 * Pentaho Data Integrator GIS Plugin
 * %%
 * Copyright (C) 2015 Atol CD
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/lgpl-3.0.html>.
 * #L%
 */


import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Feature {

    private List<Value> values;

    public Feature() {

        this.values = new ArrayList<Value>();

    }

    public List<Value> getValues() {
        return values;
    }

    public void addValue(Field field, Object value) {
        this.values.add(new Value(field, value));
    }

    public Field getField(String fieldName) {

        Iterator<Value> valueIt = this.values.iterator();
        while (valueIt.hasNext()) {

            Value value = valueIt.next();
            if (value.getField().getName().equals(fieldName)) {
                return value.getField();
            }
        }
        return null;

    }

    public Object getValue(Field field) {

        Iterator<Value> valueIt = this.values.iterator();
        while (valueIt.hasNext()) {

            Value value = valueIt.next();
            if (value.getField().getName().equals(field.getName())) {
                return value.getValue();
            }
        }
        return null;

    }

}
